﻿$import( "SmitearWebGL.IO.Loader" );
$import( "SmitearWebGL.Events.FileLoadEvent" );

SmitearWebGL.IO.ImageLoader = SmitearWebGL.IO.Loader.extend(
{
	/******** constructor ********/
	
	init : function()
	{
		this._super();
		this._registClass( "SmitearWebGL.IO.ImageLoader" );
	}
	,
	
	/******** public method ********/
	
	load : function( url )
	{
		var self = this;
		self.contentLoaderInfo.url = url;
		self.contentLoaderInfo.content = new Image();
		self.contentLoaderInfo.content.onload = function()
		{
			self.contentLoaderInfo.width = self.contentLoaderInfo.content.width;
			self.contentLoaderInfo.height = self.contentLoaderInfo.content.height;
			self.contentLoaderInfo.dispatchEvent( new SmitearWebGL.Events.FileLoadEvent( SmitearWebGL.Events.FileLoadEvent.FILE_LOAD_COMPLETE, url ) );
		}
		self.contentLoaderInfo.content.onerror = function()
		{
			self.contentLoaderInfo.dispatchEvent( new SmitearWebGL.Events.FileLoadEvent( SmitearWebGL.Events.FileLoadEvent.LOAD_ERROR, url ) );
		}
		this.contentLoaderInfo.content.src = url;
	}
}
);
